package cn.csc.module.product.api.sku;

import cn.csc.framework.common.pojo.CommonResult;
import cn.csc.module.product.api.sku.dto.SkuDTO;
import cn.csc.module.product.convert.sku.SkuConvert;
import cn.csc.module.product.service.sku.SkuService;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigInteger;
import java.util.List;

import static cn.csc.framework.common.pojo.CommonResult.success;
import static cn.csc.module.product.enums.ApiConstants.VERSION;

/**
 * spu api
 * @author liuchuang
 * @version 1.0
 * @date 2024/1/25 14:55
 * @modify
 */
@RestController // 提供 RESTful API 接口，给 Feign 调用
@DubboService(version = VERSION) // 提供 Dubbo RPC 接口，给 Dubbo Consumer 调用
@Validated
public class SkuApiImpl implements SkuApi {

    @Autowired
    private SkuService skuService;


    @Override
    public CommonResult<SkuDTO> getSku(BigInteger id) {
        return success(SkuConvert.INSTANCE.convertDTO(skuService.getSku(id)));
    }

    @Override
    public CommonResult<List<SkuDTO>> getSkuList(List<BigInteger> skuIds) {
        return success(SkuConvert.INSTANCE.convertList05(skuService.getSkuList(skuIds)));
    }

}
